package com.ssm.lzh.controller;


import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.lzh.service.FoodService;
import com.ssm.pojo.Food;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/lzh")
public class FoodController {

    @Resource
    private FoodService foodService;


    @RequestMapping("/queryAllFood")
    @ResponseBody
    public PageInfo<Food> queryAllExercise(@RequestBody Page<Food> page){
        return this.foodService.queryAllFood(page);
    }


    @RequestMapping("/addFood")
    @ResponseBody
    public int addFood(@RequestBody Food food){
        return this.foodService.addFood(food);
    }

    @RequestMapping("/UpdateFood")
    @ResponseBody
    public int updateFood(@RequestBody Food food){
        return this.foodService.updateFood(food);
    }

    @RequestMapping("/deleteFood")
    @ResponseBody
    public int deleteFood(String id){
        System.out.println(id);
        return this.foodService.deleteFood(id);
    }

}
